import verifys from 'service/util/verifys'
import reg from 'service/config/reg.js'

export default {
    data() {
        return {
            showSetSuccess: false,
            mobile: '',
            password: '',
            smsCode: '',
            picCode: '',
            reauth: 0
        }
    },
    computed: {
        showAuth() {
            return reg.mobile.test(this.mobile)
        }
    },
    methods: {
        // 忘记密码-修改密码请求发送
        doForgetPwd() {
            if (verifys.verify(['mobile', 'smsCode', 'password'], this)) {
                var { mobile, smsCode, password } = this
                $ajax.account.forgetPwd({ mobile, smsCode, password }).then(res => {
                    var { code, msg } = res.data
                    $toast.show(msg)
                    if (code == 'S') {
                        this.$router.replace('/user/login')
                    }
                }).catch(err => {
                    $toast.show('网络异常')
                })
            }
        },
        failSms() {
            this.reauth++
            this.picCode = ''
        }
    }
}